# -*- coding: utf-8 -*-

import os
import importlib.util

PYTHON_FILE_HEADER = '# -*- coding: utf-8 -*-'
PYTHON_INDENT = '    '


def py_load_from_path(filepath: str):
    if not os.path.isfile(filepath):
        raise Exception('Failed to find file {}'.format(filepath))
    # Load the module from filepath.
    module_spec = importlib.util.spec_from_file_location('', filepath)
    module = importlib.util.module_from_spec(module_spec)
    # Execute the module.
    module_spec.loader.exec_module(module)
    # Give back the module.
    return module